//
// Created by bleedingfight on 2020/6/28.
//
#include "findNumberIn2DArray.h"
bool findNumberIn2DArray(std::vector<std::vector<int>>& matrix, int target){
    bool found = false;
    if(matrix.size() == 0)
        return found;
    int rows = matrix.size();
    int cols = matrix[0].size();
    int col=cols-1;
    int row = 0;
    while (row<rows && col>=0){
        if(matrix[row][col] == target)
        {
            found = true;
            break;
        }else if(matrix[row][col]>target)
            col--;
        else
            row++;
    }
    return found;
}
